import { CommonModal } from "@/pages/OrderModule/common/components/CommonModal";
import Typography from "@/pages/OrderModule/common/components/Typography";
import { cancelFreightIntercept } from "../../../../services";
import CommonLoading from "@/components/CommonLoading";
import { useState } from "react";
import { message } from "antd";

/** 设置强制发货 */
function SetForcedSendGoodsModal(props) {
	const [loading, setLoading] = useState(false);

	const { selectKeys, handleCancel, handleOk } = props;

	//取消运费拦截
	const handleCancelFreightIntercept = async () => {
		setLoading(true);
		const { success, msg = "" } = await cancelFreightIntercept(selectKeys);
		if (success) {
			message.info(msg);
			handleOk();
		}
		setLoading(false);
	};

	return (
		<CommonModal
			title={{ title: "取消运费拦截" }}
			open={true}
			width="440px"
			onOk={handleCancelFreightIntercept}
			onCancel={handleCancel}
		>
			<div style={{ lineHeight: "30px", fontWeight: 500, color: "#333" }}>
				取消运费拦截的订单，仓库发货将不再考虑快递差价问题。
				<br />
				是否<Typography type="error">取消运费拦截</Typography>
			</div>
			<CommonLoading loading={loading} />
		</CommonModal>
	);
}

export default SetForcedSendGoodsModal;
